home *** CD-ROM | disk | FTP | other *** search
- '****************************************************************************
- '* 11/1/88 VER 2.0 *
- '* *** DIAL DOS LINE PHONE DIALER **** *
- '* Written in *
- '* QUICKBASIC 4.0 *
- '* *
- '* (c) 1988 by DAVID WESSON, PhD. 238 S. Quaker La. W.Hartford, CT 06119 *
- '****************************************************************************
- '
- ' $INCLUDE: 'dial.dec'
- '
- '========================== MAIN PROGRAM STARTS HERE ========================
- initialize
- header
- readcommandline
- goodbye
- '======================= DECLARED SUBROUTINES START HERE ====================
-
- SUB addnames
- PRINT "ADDING names and phone numbers to Directory."
- getnames
- sortdatafile
- writedatafile
- END SUB
-
- SUB checkdatafile
-
- Check.for.datafile:
- datafile = FREEFILE
- OPEN datafile$ FOR RANDOM AS datafile
- IF LOF(datafile) = 0 THEN
- CLOSE datafile
- KILL datafile$
- makedir
- CLS
- END IF
- CLOSE datafile
-
- Check.for.prefix:
- opendatafile
- LINE INPUT #datafile, top$
- IF INSTR(top$, quote$) = 0 THEN
- DIM datalines$(max)
- top$ = top$ + comma$ + quote$ + prefix$ + quote$
- WHILE NOT EOF(datafile)
- x = x + 1
- LINE INPUT #datafile, datalines$(x)
- WEND
- CLOSE datafile
- KILL datafile$
- OPEN datafile$ FOR OUTPUT AS datafile
- PRINT #datafile, top$
- FOR n = 1 TO x
- PRINT #datafile, datalines$(n)
- NEXT n
- END IF
- CLOSE datafile
-
- Check.for.portdata:
- readdatafile
- IF LEN(port$) = 1 THEN port$ = "COM" + port$ + ":"
- IF LEN(port$) + LEN(tone$) <> 6 THEN
- PRINT "ERROR: Error in top line of DIAL.DAT file. Hit any key for instructions."
- getkey
- helpscreen
- END IF
- END SUB
-
- SUB checkkeyboard
- keyhit = 0
- in$ = INKEY$
- IF in$ <> "" THEN keyhit = 1
- clock
- END SUB
-
- SUB clock
- fixtime
- row = CSRLIN
- col = POS(0)
- LOCATE 1, 40: PRINT newtime$
- LOCATE row, col
- END SUB
-
- SUB deletename
- PRINT "DELETING names from Directory."
- DO
- found = 0
- PRINT ""
- INPUT "Enter FULL NAME, or Blank to EXIT : ", name$
- IF name$ = "" OR name$ = esc$ THEN EXIT DO
- name$ = UCASE$(name$)
- FOR x = 1 TO n
- IF name$(x) = name$ THEN found = 1
- name$(x) = name$(x + found)
- number$(x) = number$(x + found)
- NEXT x
- n = n - found
- IF found = 0 THEN
- PRINT "No listing by that name in Directory."
- PRINT " Hit D to view Directory,"
- PRINT " A to try Again or"
- PRINT " any other key to EXIT."
- getkey
- SELECT CASE in$
- CASE "D"
- showdir
- CASE "A"
- donothing
- CASE ELSE
- EXIT DO
- END SELECT
- END IF
- LOOP
- writedatafile
- PRINT ""
- PRINT "Modifying DIAL.DAT. Type DIAL DIR to view Directory."
- END SUB
-
- SUB demondial
- demon = 1
- DO
- try = try + 1
- header
- placecall
- LOOP
- END SUB
-
- SUB dialfromlist
- openphonelist
- opentempfile
- add$ = ""
- PRINT "Add PREFIX CODE to all numbers? ( Y / N ): ",
- getkey
- PRINT in$
- PRINT ""
- IF in$ = "Y" THEN add$ = prefix$
- DO WHILE NOT EOF(phonelist)
- INPUT #phonelist, call$, dial$
- olddial$ = dial$
- dial$ = add$ + dial$
- placecall
- PRINT "Hang up phone, then"
- PRINT "Hit S to Save this number for future reference."
- PRINT " E to Exit dialing after saving this number."
- PRINT " Q to Quit dialing without saving this number."
- PRINT " or D to Dial next number without saving this one."
- askkey:
- getkey
- SELECT CASE in$
- CASE "S"
- WRITE #tempfile, call$, olddial$
- CASE "E"
- WRITE #tempfile, call$, olddial$
- EXIT DO
- CASE "Q"
- EXIT DO
- CASE "D"
- donothing
- CASE ELSE
- GOTO askkey
- END SELECT
- LOOP
- loftemp = LOF(tempfile)
- CLOSE phonelist
- CLOSE tempfile
- IF loftemp = 0 THEN
- KILL tempfile$
- ELSE INPUT "Name for list of saved names: ", savelist$
- IF savelist$ = "" OR savelist$ = phonelist$ OR savelist$ = datafile$ THEN saved$ = "REDIAL.LST"
- NAME tempfile$ AS savelist$
- PRINT "Saving names in file called "; savelist$
- END IF
- END SUB
-
- SUB donothing
- 'this sub is a dummy
- END SUB
-
- SUB editname
- PRINT "EDITING names and phone numbers in Directory."
- DO
- found = 0
- PRINT ""
- row = CSRLIN
- INPUT "Enter full or partial NAME, or Blank to END: ", name$
- IF name$ = "" OR nam$ = esc$ THEN EXIT DO
- name$ = UCASE$(name$)
- FOR x = 1 TO n
- IF LEFT$(name$(x), LEN(name$)) = name$ THEN
- LOCATE row, 46: PRINT name$(x)
- found = 1
- INPUT "Enter NEW name or [Return] to leave as is : ", newname$
- IF newname$ <> "" THEN name$(x) = UCASE$(newname$)
- INPUT "Enter NEW number or [Return] to leave as is: ", newnumber$
- IF newnumber$ <> "" THEN number$(x) = newnumber$
- END IF
- NEXT x
- IF found = 0 THEN
- PRINT "No listing by that name in Directory."
- PRINT " Hit D to view Directory,"
- PRINT " A to try Again or"
- PRINT " any other key to EXIT."
- getkey
- SELECT CASE in$
- CASE "D"
- showdir
- CASE "A"
- donothing
- CASE ELSE
- EXIT DO
- END SELECT
- END IF
- LOOP
- sortdatafile
- writedatafile
- END SUB
-
- SUB fixtime
- intime$ = TIME$ 'current time changed
- hour$ = MID$(intime$, 1, 2) 'to newtime$
- min$ = MID$(intime$, 4, 2)
- sec$ = MID$(intime$, 7, 2)
- hour = VAL(hour$)
- IF hour < 12 THEN ampm$ = "am" ELSE ampm$ = "pm"
- IF hour > 12 THEN hour = hour - 12
- hour$ = STR$(hour)
- newtime$ = hour$ + ":" + min$ + ":" + sec$ + " " + ampm$
- END SUB
-
- SUB getkey
- in: in$ = INKEY$
- IF in$ = "" THEN clock: GOTO in
- in$ = UCASE$(in$)
- END SUB
-
- SUB getnames
- PRINT ""
- PRINT "Enter names or blank line to end input."
- PRINT "Enter numbers, use - hyphens for pauses only."
- DO
- PRINT ""
- INPUT "Enter NAME or Blank to EXIT : ", name$
- IF name$ = "" THEN EXIT DO
- n = n + 1
- name$(n) = UCASE$(name$)
- INPUT "Enter NUMBER, use - for pause: ", number$
- number$(n) = number$
- LOOP
- END SUB
-
- SUB goodbye
- PRINT ""
- CLOSE
- END
- END SUB
-
- SUB hangup
- PRINT #port, "ATH0"
- PRINT "Modem hung-up."
- CLOSE port
- END SUB
-
- SUB header
- fixtime
- CLS
- COLOR 15: PRINT "DIAL"; : COLOR 7: PRINT " Command Line Phone Dialer v2.0 "; newtime$
- END SUB
-
- SUB helpscreen
- PRINT "Syntax: DIAL name full name or unique first part of name"
- PRINT " or MAKE MAKES a Directory file. Use ONCE only."
- PRINT " or DIR VIEW Directory of names and numbers"
- PRINT " or ADD ADD names to Directory"
- PRINT " or DEL DELETE a name in the Directory. Use full name."
- PRINT " or EDIT EDIT a name or number in the Directory"
- PRINT " or @file get names and #s from list called file"
- PRINT " or PRE set prefix code sequence *"
- PRINT " or *number dial prefix before number"
- PRINT " or *name dial prefix before name"
- PRINT " or number dialing a number not in the Directory"
- PRINT " (insert - hyphen for two second pause)"
- PRINT ""
- PRINT "NOTE: This program assumes use of the Hayes command set.";
- goodbye
- END SUB
-
- SUB hyphen
- FOR D = 1 TO LEN(dial$)
- IF MID$(dial$, D, 1) = "-" THEN
- MID$(dial$, D, 1) = ","
- END IF
- NEXT D
- END SUB
-
- SUB initialize
- max = 480
- DIM srtn(max)
- DIM name$(max)
- DIM number$(max)
- esc$ = CHR$(27)
- quote$ = CHR$(34)
- comma$ = CHR$(44)
- datafile$ = "dial.dat"
- tempfile$ = "dial.tmp"
- logfile$ = "dial.log"
- END SUB
-
- SUB logcall
- PRINT ""
- PRINT "When phone is answered, hit L to LOG call, "
- PRINT "or else any other key to EXIT."
- PRINT ""
- getkey
- IF in$ <> "L" THEN EXIT SUB
- openlogfile
- fixtime
- ontime$ = newtime$
- onhour = VAL(hour$)
- onmin = VAL(min$)
- onsec = VAL(sec$)
- PRINT ""
- PRINT "At end of call, hit any key to log time."
- PRINT "Time: 00:00";
- start = TIMER
- timeout
- PRINT ""
- PRINT "Call to "; call$; " logged in DIAL.LOG."
- PRINT #logfile, DATE$, LEFT$(call$, 12), dial$, ontime$, offtime$, tottime$
- CLOSE logfile
- END SUB
-
- SUB makedir
- PRINT "==============================================================================="
- PRINT "DIAL will not run without first preparing a Directory file called DIAL.DAT"
- PRINT "Please answer at least the first three prompts. No names needed at this time."
- COLOR 15
- PRINT "WARNING: ";
- COLOR 7
- PRINT "If you proceed with this, any existing DIAL.DAT file will be replaced."
- PRINT " Hit [Esc] to EXIT or any key to continue."
- PRINT "==============================================================================="
- PRINT ""
- getkey
- IF in$ = esc$ THEN END
- PRINT ""
- PRINT "Enter the port NUMBER ( if in doubt, type 1 ) : ";
- getkey
- port$ = "com" + in$ + ":"
- PRINT port$
- PRINT ""
- PRINT "Enter the dialtone TYPE ( P = Pulse, T = Tone ): ";
- getkey
- tone$ = in$
- PRINT tone$
- PRINT ""
- setprefix
- PRINT ""
- addnames
- END SUB
-
- SUB opendatafile
- datafile = FREEFILE
- OPEN datafile$ FOR INPUT AS datafile
- END SUB
-
- SUB openlogfile
- logfile = FREEFILE
- OPEN logfile$ FOR APPEND AS logfile
- END SUB
-
- SUB openphonelist
- phonelist = FREEFILE
- OPEN phonelist$ FOR INPUT AS phonelist
- END SUB
-
- SUB openport
- port = FREEFILE
- OPEN port$ FOR RANDOM AS port
- END SUB
-
- SUB opentempfile
- tempfile = FREEFILE
- OPEN tempfile$ FOR OUTPUT AS tempfile
- END SUB
-
- SUB placecall
- IF demon = 1 THEN
- PRINT "DEMON-DIALING your call to "; call$; ". TRY"; try
- ELSE PRINT "Your call to "; call$; " is dialing."
- END IF
- PRINT "Hit any key to HANG UP modem. Please wait . . ."
- checkkeyboard
- IF keyhit = 1 THEN goodbye
- openport
- PRINT #port, "AT X6 Q0 V1 D" + tone$ + dial$
- DO
- checkkeyboard
- IF keyhit = 1 THEN GOTO getout
- income = LOC(port)
- IF income <> 0 THEN modem$ = INPUT$(1, #port)
- SELECT CASE modem$
- CASE "B"
- hangup
- IF demon = 1 THEN EXIT SUB
- PRINT "Line busy. Hit [SpaceBar] to redial once,"
- PRINT " or hit D to demon-dial until it connects,"
- PRINT " or hit any other key to exit."
- getkey
- SELECT CASE in$
- CASE CHR$(32)
- header
- placecall
- CASE "D"
- demondial
- EXIT DO
- CASE ELSE
- goodbye
- END SELECT
- CASE "R"
- EXIT DO
- CASE ELSE
- donothing
- END SELECT
- LOOP
- PRINT "Pick up the receiver, THEN hit any key to hang up modem."
- ring
- getout:
- hangup
- logcall
- IF demon = 1 THEN goodbye
- END SUB
-
- SUB qsort (srtn(), mid)
- DIM newname$(n), newnumber$(n), newsrtn(n)
- y = 0: z = 1
- FOR x = 1 TO n
- IF srtn(x) > mid THEN
- newsrtn(n - y) = srtn(x)
- newname$(n - y) = name$(x)
- newnumber$(n - y) = number$(x)
- y = y + 1
- ELSE newsrtn(z) = srtn(x)
- newname$(z) = name$(x)
- newnumber$(z) = number$(x)
- z = z + 1
- END IF
- NEXT x
- y = y - 1
- z = z - 1
- FOR t = 1 TO n
- name$(t) = newname$(t)
- number$(t) = newnumber$(t)
- srtn(t) = newsrtn(t)
- NEXT t
- ERASE newname$, newnumber$, newsrtn
- PRINT "Total Names:"; n; TAB(20); "Sorting #";
- FOR x = 1 TO y
- FOR w = 1 TO z - x
- IF srtn(x) > srtn(x + w) THEN
- SWAP srtn(x), srtn(x + w)
- SWAP name$(x), name$(x + w)
- SWAP number$(x), number$(x + w)
- END IF
- NEXT w
- LOCATE , 29: PRINT x;
- NEXT x
- FOR x = y + 1 TO n
- FOR y = 1 TO n - x
- IF srtn(x) > srtn(x + y) THEN
- SWAP srtn(x + y), srtn(x)
- SWAP name$(x + y), name$(x)
- SWAP number$(x + y), number$(x)
- END IF
- NEXT y
- LOCATE , 29: PRINT x;
- NEXT x
- PRINT ""
- END SUB
-
- SUB readcommandline
- inline$ = UCASE$(COMMAND$)
- IF inline$ = "" THEN
- helpscreen
- ELSE checkdatafile
- END IF
- mark$ = LEFT$(inline$, 1)
- SELECT CASE inline$
- CASE "MAKE"
- makedir
- CASE "ADD"
- addnames
- CASE "DEL"
- deletename
- CASE "DIR"
- showdir
- CASE "EDIT"
- editname
- CASE "PRE"
- setprefix
- writedatafile
- CASE ELSE
- IF mark$ = "@" THEN
- phonelist$ = MID$(inline$, 2)
- dialfromlist
- END IF
- IF mark$ = "*" THEN
- IF prefix$ = "" THEN setprefix
- inline$ = MID$(inline$, 2)
- add$ = prefix$
- END IF
- IF VAL(LEFT$(inline$, 1)) > 0 AND VAL(LEFT$(inline$, 1)) < 9 THEN
- call$ = inline$
- dial$ = add$ + inline$
- hyphen
- placecall
- goodbye
- END IF
- FOR x = 1 TO n
- IF LEFT$(name$(x), LEN(inline$)) = inline$ THEN
- call$ = name$(x)
- dial$ = add$ + number$(x)
- END IF
- NEXT x
- hyphen
- IF call$ = "" THEN
- header
- PRINT "No listing found for "; inline$; " in the Directory."
- PRINT "Hit D to review Directory or any other key to EXIT."
- getkey
- IF in$ = "D" THEN showdir
- ELSE placecall
- END IF
- END SELECT
- END SUB
-
- SUB readdatafile
- opendatafile
- INPUT #datafile, port$, tone$, prefix$
- WHILE NOT EOF(datafile)
- n = n + 1
- INPUT #datafile, name$(n), number$(n)
- WEND
- CLOSE datafile
- END SUB
-
- SUB ring
- DO
- FOR x = 1 TO 5
- SOUND 850, .85
- SOUND 650, .85
- NEXT x
- in$ = INKEY$
- IF in$ <> "" THEN EXIT SUB
- time1 = TIMER
- DO
- time2 = TIMER
- IF INKEY$ <> "" THEN EXIT SUB
- LOOP UNTIL time2 = time1 + 4
- LOOP
- END SUB
-
- SUB setprefix
- PRINT "Enter PREFIX using - (hyphen) for 2 second pause."
- INPUT "PREFIX CODE: ", prefix$
- END SUB
-
- SUB showdir
- DO
- header
- y = 1
- FOR w = 1 TO 2
- FOR x = 2 TO 22
- z = z + 1
- IF name$(z) = "" THEN EXIT DO
- LOCATE x, y: PRINT name$(z); TAB(20 + y); number$(z)
- NEXT x
- y = 45
- NEXT w
- LOCATE 24, 20: COLOR 15: PRINT "Press any key for more names"; : COLOR 7
- getkey
- LOOP
- IF prefix$ <> "" THEN LOCATE 23, 45: PRINT "PREFIX CODE * = "; prefix$
- LOCATE 24, 20: COLOR 15: PRINT "Press any key to EXIT directory"; : COLOR 7
- getkey
- CLS
- END SUB
-
- SUB sortdatafile
- PRINT "Preparing to sort Directory."
- x = 1
- FOR x = 1 TO n
- srtn(x) = 1
- FOR z = 1 TO 4
- letter$ = MID$(name$(x), z, 1)
- IF letter$ = "" OR letter$ < CHR$(65) OR letter$ > CHR$(90) THEN
- srtn(x) = srtn(x) * 100
- ELSE srtn(x) = (srtn(x) * 100) + (ASC(letter$) - 64)
- END IF
- NEXT z
- stotal = stotal + srtn(x)
- NEXT x
- IF n = 0 THEN EXIT SUB
- mid = stotal / n
- qsort srtn(), mid
- PRINT "DIAL.DAT modified. Type DIAL DIR to view Directory."
- END SUB
-
- SUB timeout
- DO WHILE INKEY$ = ""
- clock
- DO UNTIL sec >= start + 1
- sec = TIMER
- LOOP
- start = start + 1
- d1 = d1 + 1
- IF d1 = 10 THEN
- d2 = d2 + 1
- d1 = 0
- END IF
- IF d2 = 6 THEN
- d3 = d3 + 1
- d2 = 0
- END IF
- IF d3 = 10 THEN
- d4 = d4 + 1
- d3 = 0
- END IF
- IF d4 = 10 THEN d4 = 0
- d1$ = LTRIM$(STR$(d1)): d2$ = LTRIM$(STR$(d2))
- d3$ = LTRIM$(STR$(d3)): d4$ = LTRIM$(STR$(d4)):
- tottime$ = d4$ + d3$ + ":" + d2$ + d1$
- LOCATE , 7: PRINT tottime$;
- LOOP
- fixtime
- offtime$ = newtime$
- END SUB
-
- SUB writedatafile
- datafile = FREEFILE
- OPEN datafile$ FOR OUTPUT AS datafile
- WRITE #datafile, port$, tone$, prefix$
- FOR x = 1 TO n
- WRITE #datafile, name$(x), number$(x)
- NEXT x
- CLOSE datafile
- END SUB
-
-